<template>
	<view class="wrap">
		<u-form :model="model" :rules="rules" ref="uForm">
			<u-form-item label-width="350"
				:label-position="labelPosition" label="气层顶界深度(m)" prop="gasTopDepth">
				<u-input :border="border" placeholder="请输入气层顶界深度" v-model="model.gasTopDepth" type="digit"></u-input>
			</u-form-item>
			<u-form-item label-width="350"
				:label-position="labelPosition" label="管脚深度(m)" prop="pipeFootDepth">
				<u-input :border="border" placeholder="请输入管脚深度" v-model="model.pipeFootDepth" type="digit"></u-input>
			</u-form-item>
			<u-form-item label-width="350"
				:label-position="labelPosition" label="气体从开泵到地面返出的时间(h)" prop="pumpToSurfaceTime">
				<u-input :border="border" placeholder="请输入气体从开泵到地面返出的时间" v-model="model.pumpToSurfaceTime" type="digit"></u-input>
			</u-form-item>
			<u-form-item label-width="350"
				:label-position="labelPosition" label="从管脚上返到地面所需的时间(h)" prop="footToSurfaceTime">
				<u-input :border="border" placeholder="请输入从管脚上返到地面所需的时间" v-model="model.footToSurfaceTime" type="digit"></u-input>
			</u-form-item>
			<u-form-item label-width="350"
				:label-position="labelPosition" label="从起管柱到下管柱所用的时间(h)" prop="pipeOperationTime">
				<u-input :border="border" placeholder="请输入从起管柱到下管柱所用的时间" v-model="model.pipeOperationTime" type="digit"></u-input>
			</u-form-item>
		</u-form>

		<u-button type="primary" @click="submit">计算</u-button>

		<view class="u-config-wrap">
			<view class="u-config-item">
				<view class="u-item-title">计算结果</view>
				<u-form-item style="font-size: 22px;" :leftIconStyle="{color: '#888', fontSize: '32rpx'}" label-width="300"
					:label-position="labelPosition" label="气体上返速度" prop="gasRiseVelocity">
					<span v-if="model.gasRiseVelocity"> {{model.gasRiseVelocity}} m/h </span>
				</u-form-item>
			</view>
			<view class="u-config-item">
				<view class="u-item-title">计算公式</view>
				<view class="u-item-desc">V = (H气顶深 - (H管脚深度 × T显示) ÷ T迟到) ÷ T静止</view>
				<view class="u-item-desc">式中：</view>
				<view class="u-item-desc">V — 气体上返速度，m/h</view>
				<view class="u-item-desc">H气顶深 — 气层顶界深度，m</view>
				<view class="u-item-desc">H管脚深度 — 即洗井深度，m</view>
				<view class="u-item-desc">T显示 — 气体从开泵到地面返出的时间，h</view>
				<view class="u-item-desc">T迟到 — 从管脚上返到地面所需的时间，h</view>
				<view class="u-item-desc">T静止 — 从起管柱到下管柱所用的时间，h</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				model: {
					gasTopDepth: '',
					pipeFootDepth: '',
					pumpToSurfaceTime: '',
					footToSurfaceTime: '',
					pipeOperationTime: '',
					gasRiseVelocity: ''
				},
				rules: {
					gasTopDepth: [{
						required: true,
						message: '请输入气层顶界深度',
						trigger: 'blur'
					}],
					pipeFootDepth: [{
						required: true,
						message: '请输入管脚深度',
						trigger: 'blur'
					}],
					pumpToSurfaceTime: [{
						required: true,
						message: '请输入气体从开泵到地面返出的时间',
						trigger: 'blur'
					}],
					footToSurfaceTime: [{
						required: true,
						message: '请输入从管脚上返到地面所需的时间',
						trigger: 'blur'
					}],
					pipeOperationTime: [{
						required: true,
						message: '请输入从起管柱到下管柱所用的时间',
						trigger: 'blur'
					}]
				},
				labelPosition: 'left',
				border: true,
				
			};
		},
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		},
		methods: {
			submit() {
				this.$refs.uForm.validate(valid => {
					if (valid) {
						const H气顶深 = parseFloat(this.model.gasTopDepth);
						const H管脚深度 = parseFloat(this.model.pipeFootDepth);
						const T显示 = parseFloat(this.model.pumpToSurfaceTime);
						const T迟到 = parseFloat(this.model.footToSurfaceTime);
						const T静止 = parseFloat(this.model.pipeOperationTime);
						
						// 计算气体上返速度 V = (H气顶深 - (H管脚深度 × T显示) ÷ T迟到) ÷ T静止
						this.model.gasRiseVelocity = ((H气顶深 - (H管脚深度 * T显示) / T迟到) / T静止).toFixed(2);
					}
				});
			}
		}
	};
</script>

<style scoped lang="scss">
	.wrap {
		padding: 30rpx;
	}

	.u-config-wrap {
		margin-top: 30rpx;
	}

	.u-config-title {
		padding: 20rpx;
		font-size: 32rpx;
		font-weight: bold;
	}

	.u-config-item {
		padding: 20rpx;
	}

	.u-item-title {
		font-size: 28rpx;
		font-weight: bold;
		margin-bottom: 10rpx;
	}

	.u-item-desc {
		font-size: 24rpx;
		color: #666;
	}
</style> 